package cn.enilu.flash.dao.system;


import cn.enilu.flash.bean.entity.system.User;
import cn.enilu.flash.dao.BaseRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;

/**
 * Created  on 2018/3/21 0021.
 *
 * @author enilu
 */
public interface UserRepository extends BaseRepository<User,Long> {
    User findByAccount(String account);

    User findByAccountAndStatusNot(String account, Integer status);

    @Modifying
    @Transactional
    @Query(nativeQuery = true,value = "update t_sys_user set policy_retry_count = 0 where account = ?1")
    void resetRetryCount(String account);


    @Modifying
    @Transactional
    @Query(nativeQuery = true,value = "update t_sys_user set policy_retry_count = policy_retry_count +1, policy_fail_time = now() where account = ?1")
    void updateRetryCount(String account);

}
